﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SLogo.Helper
{
    class FileHelper
    {
        /// <summary>
        /// 检查文件是否存在
        /// </summary>
        /// <returns></returns>
        public static bool IsFileExist(String file)
        {
            if (File.Exists(file) || File.Exists(Directory.GetCurrentDirectory() + file))
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 获得文件内容
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static String ReadFile(String filename)
        {
            String str = "";
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs, Encoding.Default);
            //开始写入
            str = sr.ReadToEnd();
            //关闭流
            sr.Close();
            fs.Close();
            return str;
        }
    }
}
